# Copyright (c) 2022 Robert Bosch GmbH and Microsoft Corporation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0

# syntax=docker/dockerfile:1.2

# Build stage, to create the executable
#FROM --platform=linux/arm64 localhost/python_sdk:3.10-slim-bullseye_arm64 as builder
FROM --platform=linux/arm64 192.168.88.50/sdvos_velocitas_base_image/python_sdk@sha256:28531c0bb82f5e919dc7ea2cfb2e2c68e236c8ae852a9389f337770bb827345c as builder

COPY ./app /app

#RUN pip3 install --no-cache-dir -r ./app/requirements-app.txt \
#    && pip3 install --no-cache-dir -r ./app/requirements-links.txt

WORKDIR /app

RUN pyinstaller --clean --collect-all opentelemetry-sdk  -F -s src/main.py

WORKDIR /app/dist

RUN staticx main run-exe

# Runner stage, to copy the executable
FROM scratch

COPY --from=builder ./app/dist/run-exe /dist/

WORKDIR /tmp
WORKDIR /dist

ENV PATH="/dist:$PATH"

LABEL org.opencontainers.image.source="https://github.com/eclipse-velocitas/vehicle-app-python-template"

CMD ["./run-exe"]
